<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.alibaba.appengine.api.store.*"%>
<%@page import="com.alibaba.appengine.api.fetchurl.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>ACE基础功能测试</title>
<link rel="stylesheet"
	href="script/jquery-ui-1.10.4/themes/base/jquery.ui.all.css">
<script src="script/jquery-ui-1.10.4/jquery-1.10.2.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.core.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.widget.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.mouse.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.button.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.draggable.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.position.js"></script>
<script src="script/jquery-ui-1.10.4/ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="script/jquery-ui-1.10.4/demos/demos.css">
<script>
	//当页面加载完毕时添加一个隐藏的div
	$(function() {

		/* $.get("index2.jsp", function(data){
				  console.info(data);
				  $("#form_container").html(data);
				}); */

	});
</script>
</head>

<body>
	<div id="form_container"></div>
	<%
		out.write("Begin store service test.");
		StoreService storeService = StoreServiceFactory.getStoreService();

		final String testText = "FooText";
		final String textPath = "/test.txt";

		out.write("Save text " + testText + " to file " + textPath + ".\n");
		storeService.saveTextFile(testText, path);

		String getText = storeService.getTextFile(path);
		out.write("Read text " + getText + " from file " + textPath + ".\n");

		if (testText.equals(getText)) {
			out.write("Store service test ok!");
		} else {
			out.write("Fail to get, expect " + testText + ", actual "
					+ getText + "!\n");
		}

		out.write("Begin fetchurl service test.");
		FetchUrlService fetchUrlService = FetchUrlServiceFactory
				.getFetchUrlService();

		final String url = "http://www.taobao.com";
		String body = fetchUrlService.get(url);
		out.write("Fetch text from url" + url + ":"
				+ body.substring(0, 256) + "...\n");
	%>
</body>
</html>
